let arr = [100, 200, [300, 400, [500, 600]]]; //2100

// let total = 0;
function f(arr, total = 0) {
  arr.forEach((item, index) => {
    if (typeof item == "number") {
      return (total += item);
    } else {
      console.log(total, index);
      return f(item, total);
    }
  });
  return total;
}

let result = f(arr);
console.log(result);

// console.log(total);
